﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HousingDistribution
{
    class DGVInit
    {
        static public void Init(ref DataGridView dgv, DataDictionary.DGVConf[] confs)
        {
            dgv.AutoGenerateColumns = false;

            foreach (DataDictionary.DGVConf conf in confs)
            {
                DataGridViewColumn col = null;

                if (conf.type != null && conf.type == "checkbox")
                {
                    col = new DataGridViewCheckBoxColumn();
                    col.Selected = false;
                }
                else
                {
                    col = new DataGridViewTextBoxColumn();
                }

                col.Name = conf.name;
                col.HeaderText = conf.title;
                col.DataPropertyName = conf.name;
                col.ReadOnly = conf.readOnly;
                col.Visible = conf.visible;
                col.Width = conf.width;

                dgv.Columns.Add(col);
            }
        }
    }
}
